<?php
require_once '../sub/init.php';
header("Cache-control: private");
require_once 'chkUadm.php';
if(!in_array('qun',$QXARR))exit(noauth());
require_once ZEAI.'cache/udata.php';
if ( !ifint($fid))callmsg("www_zeai_cn_error_fid","-1");
$row  = $db->ROW(__TBL_QUN__,"uid","id=".$fid,"name");
$quid = ($row)?intval($row['uid']):0;
if($submitok=='ajax_del'){
	if (!ifint($id))json_exit(array('flag'=>0,'msg'=>'成员不存在'));
	$row = $db->ROW(__TBL_QUN_U__,"uid","qid=".$fid." AND id=".$id);
	if ($row){$uid= $row[0];}else{json_exit(array('flag'=>0,'msg'=>'成员不存在'));}
	$db->query("DELETE FROM ".__TBL_QUN_U__." WHERE qid=".$fid." AND id=".$id);
	if($quid==$uid)$db->query("UPDATE ".__TBL_QUN__." SET uid=0 WHERE id=".$fid);
	AddLog('【单身群】删除成员->【uid:'.$uid.'】');
	json_exit(array('flag'=>1,'msg'=>'删除成功'));
}elseif($submitok=='addupdate'){
	if (!ifint($Skey_uid))alert_adm("请输入合法的用户UID","-1");
	$row = $db->ROW(__TBL_USER__,"id","id=".$Skey_uid);
	if(!$row)alert_adm("此用户在用户库中不存在","-1");
	$row = $db->ROW(__TBL_QUN_U__,"id","qid=".$fid." AND uid=".$Skey_uid);
	if ($row)alert_adm("此用户已经是群员，请不要重复添加","-1");
	$db->query("INSERT INTO ".__TBL_QUN_U__."  (qid,uid,addtime) VALUES ($fid,$Skey_uid,".ADDTIME.")");
	AddLog('【单身群】新增成员->【uid:'.$Skey_uid.'】');
	header("Location: qun_detail_u.php?fid=".$fid);
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="<?php echo HOST;?>/res/www_zeai_cn.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<link href="css/main.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css">
<style>
.listdatabox{padding:10px 0}
.listdatabox li{display:inline-block;padding:1px 5px;border:#ddd 1px solid;margin:3px;border-radius:3px;color:#888}
img.photo_s40{border-radius:2px;display:inline-block;;vertical-align:middle}
i.add{display:inline-block;color:#fff;border-radius:50px;width:16px;height:16px;text-align:center;font-size:12px;margin-right:2px}
i.wxlv{color:#31C93C;margin-right:2px}
.mylist{padding:30px}
.mylist dl{width:33%;float:left;padding:10px;text-align:center;box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box}
.mylist dl dt img{display:block;margin:0 auto 5px auto}
.mylist dl dd{width:100%;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.mylist dl dd div{line-height:24px}
</style>
</head>
<body class="body">
<?php
	$SQL  = "a.qid=".$fid;
	$FLD=",U.nickname,U.sex,U.grade,U.photo_s,U.photo_f,U.areatitle,U.birthday,U.heigh,U.edu,U.flag";
	$ORDER=" ORDER BY a.id DESC";
	$Skey = trimm($Skey);
	if (ifmob($Skey)){
		$SQL .= " AND (U.mob=$Skey) ";
	}elseif(ifint($Skey)){
		$SQL .= " AND (a.uid=$Skey) ";
	}elseif(!empty($Skey)){
		$SQL .= " AND ( U.truename LIKE '%".$Skey."%' || U.nickname LIKE '%".$Skey."%' )";
	}
	$ZEAI_SELECT= "SELECT a.id,a.uid,a.addtime".$FLD." FROM ".__TBL_QUN_U__." a,".__TBL_USER__." U WHERE ".$SQL." AND a.uid=U.id ".$ORDER;
	$rt = $db->query($ZEAI_SELECT);
	$total = $db->num_rows($rt);
	if ($total <= 0 ) {
		if (!empty($Skey)){
			echo "<div class='nodataicoS Mtop100'><i></i>暂无成员加入";
			echo "<br><br><a class='aQINGed' href='javascript:history.back(-1)'>重新筛选</a>";
			echo "</div>";
		}else{?>
        	<div class='nodataicoS Mtop100'><i></i>暂无信息</div><br><br>
            <form name="www.yzlove.com.v7.0..QQ797311" method="post" action="<?php echo SELF; ?>">
                <input name="Skey_uid" type="text" id="Skey_uid" maxlength="25" class="input size2 W100" value="<?php echo $Skey;?>" placeholder="输入UID">
                <input type="hidden" name="fid" value="<?php echo $fid;?>" />
                <input type="hidden" name="submitok" value="addupdate" />
                <button type="submit" class="btn size2 QING"><i class="ico">&#xe622;</i> 新增</button>
            </form><?php
		}
	} else {
		$page_skin = 1;$pagesize=$_ADM['admPageSize'];require_once ZEAI.'sub/page.php';?>
    <div class="navbox">
    <a href="qun_detail_u.php?fid=<?php echo $fid;?>" class="ed">成员列表<?php echo '<b>'.$total.'</b>';?></a>
    <div class="Rsobox"></div>
    <div class="clear"></div></div>
    <div class="fixedblank"></div>
    <table class="table0 W95_ Mtop10">
        <tr>
        <td align="left" class="S14">
          <form name="www.yzlove.com.v7.0..QQ7144100" method="get" action="<?php echo SELF; ?>">
            <input name="Skey" type="text" id="Skey" maxlength="25" class="input size2 W200" value="<?php echo $Skey;?>" placeholder="按UID/姓名/手机/昵称查询">
            <input type="hidden" name="fid" value="<?php echo $fid;?>" />
            <input type="hidden" name="t" value="<?php echo $t;?>" />
            <button type="submit" class="btn size2 QING"><i class="ico">&#xe6c4;</i> 搜索</button>
          </form>   
        </td>
        <td align="left" ></td>
        <td align="right">
          <form name="www.yzlove.com.v7.0..QQ797311" method="post" action="<?php echo SELF; ?>">
            <input name="Skey_uid" type="text" id="Skey_uid" maxlength="25" class="input size2 W100" value="<?php echo $Skey;?>" placeholder="输入UID">
            <input type="hidden" name="fid" value="<?php echo $fid;?>" />
            <input type="hidden" name="submitok" value="addupdate" />
            <button type="submit" class="btn size2 QING"><i class="ico">&#xe622;</i> 新增</button>
          </form>           
        </td>
        </tr>
    </table>
<div class="clear"></div>
<form id="www_zeai_cn_FORM">
    <table class="tablelist W95_ Mtop10 Mbottom50">
    <tr>
    <th width="20"><input type="checkbox" id="checkboxall1" class="checkskin checkboxall"><label for="checkboxall1" class="checkskin-label"><i class="i1"></i></label></th>
    <th width="66" align="center">&nbsp;</th>
    <th align="left">加入成员</th>
    <th align="center"></th>
    <th width="121" align="center">加入时间</th>
    <th width="34" align="center">踢除</th>
    </tr>
    <?php
    for($i=1;$i<=$pagesize;$i++) {
        $rows = $db->fetch_array($rt,'name');
        if(!$rows) break;
        $id  = $rows['id'];
		//
        $uid = $rows['uid'];
        $flag = $rows['flag'];
		$nickname = trimhtml(dataIO($rows['nickname'],'out'));
		$nickname = str_replace($Skey,"<b class='Cf00'>".$Skey."</b>",$nickname);
		$sex      = $rows['sex'];
		$grade    = $rows['grade'];
		$photo_s  = $rows['photo_s'];
		$photo_f  = $rows['photo_f'];
		$areatitle= $rows['areatitle'];
		$birthday = $rows['birthday'];
		$heigh    = $rows['heigh'];
		$edu      = $rows['edu'];
		$addtime  = YmdHis($rows['addtime']);
		//
		$birthday_str  = (@getage($birthday)<=0)?'':'<li>'.getage($birthday).'岁</li>';
		$heigh_str     = (empty($heigh))?'':'<li>'.udata('heigh',$heigh).'</li>';
		$aARR = explode(' ',$areatitle);$areatitle = $aARR[1].$aARR[2];
		$areatitle_str = (empty($areatitle))?'':'<li>'.$areatitle.'</li>';
		$edu_str       = (!ifint($edu))?'':'<li>'.udata('edu',$edu).'</li>';
		$udata_str = $birthday_str.$heigh_str.$edu_str.$areatitle_str;
		$href        = Href('crm_u',$uid);
		$photo_s_url = (!empty($photo_s) && $photo_f==1)?$_ZEAI['up2'].'/'.$photo_s:HOST.'/res/photo_s'.$sex.'.png';
		$photo_str=($quid==$uid)?'<span class="HONG">群主</span>':'';
    ?>
	<tr id="tr<?php echo $id;?>">
    <td width="20" height="30" align="left"><input type="checkbox" name="list[]" value="<?php echo $id; ?>" id="id<?php echo $id; ?>" uid="<?php echo $uid; ?>" class="checkskin"><label for="id<?php echo $id; ?>" class="checkskin-label"><i class="i1"></i></label></td>
    <td width="66" height="30" align="center">
    <div class="photo_s_box">
    	<a href="<?php echo $href;?>"><img src="<?php echo $photo_s_url; ?>"><?php echo $photo_str;?></a>
    </div>
    </td>
    <td height="30" align="left">
      <div class="listdatabox">
          <div style="margin-bottom:5px"><?php echo uicon($sex.$grade) ?> <?php echo $nickname; ?>　UID：<?php echo $uid;?></div>
          <?php echo $udata_str;?>
      </div>
    </td>
    <td height="30" align="center" class="C666">
</td>
    <td width="121" height="30" align="center" class="C999"><?php echo $addtime;?></td>
    <td width="34" align="center"<?php if ($t == 3){echo ' style="padding:10px 0"';}?>>
        <a title="踢除" fid="<?php echo $fid; ?>" clsid="<?php echo $id; ?>" class="delico"></a>
    </td>
    </tr>
    <?php } ?>
    <div class="listbottombox">
        <input type="checkbox" id="checkboxall2" class="checkskin checkboxall"><label for="checkboxall2" class="checkskin-label"><i class="i1"></i></label>　
        <button type="button" id="btnsend" value="" class="btn size2 disabled action" onClick="sendTipFn2(this);"><i class="ico">&#xe676;</i> 发送消息</button>
        <input type="hidden" name="submitok" id="submitok" value="" />
        <?php if ($total > $pagesize)echo '<div class="pagebox FR" style="margin-right:20px">'.$pagelist.'</div>'; ?></div>
    </div>
</table>
</form>
<?php }?>
<br><br><br><br>
<script>
zeai.listEach('.delico',function(obj){
	obj.onclick = function(){
		var id = parseInt(obj.getAttribute("clsid")),
		fid = parseInt(obj.getAttribute("fid"));
		zeai.confirm('确定真的要删除么？（不可恢复）',function(){
			zeai.ajax({url:'qun_detail_u'+zeai.ajxext+'submitok=ajax_del&fid='+fid+'&id='+id},function(e){var rs=zeai.jsoneval(e);
				zeai.msg(0);zeai.msg(rs.msg);
				if(rs.flag==1){setTimeout(function(){location.reload(true);},1000);}
			});
		});
	}
});
var bg = '<?php echo $_Style['list_bg']; ?>',overbg   = '<?php echo $_Style['list_overbg']; ?>',selectbg = '<?php echo $_Style['list_selectbg']; ?>';
</script>
<script src="js/zeai_tablelist.js?<?php echo $_ZEAI['cache_str'];?>"></script>
</body>
</html>
